package cn.jingyuan.swan.system.manager.impl;

import cn.jingyuan.swan.system.manager.UserIdManager;

import java.util.concurrent.atomic.AtomicLong;

public class StandAloneUserIdManager implements UserIdManager {

    private AtomicLong userId;

    public StandAloneUserIdManager() {
        userId = new AtomicLong(1000000000L);
    }

    @Override
    public Long nextId() {
        return userId.incrementAndGet();
    }

    @Override
    public void reviseId(Long initId) {
        synchronized (this) {
            userId = new AtomicLong(initId);
        }
    }

}
